package unimelb.discussiontracker.twitter.data.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import unimelb.discussiontracker.twitter.data.dao.ITopicIntervalAssociationDao;
import unimelb.discussiontracker.twitter.data.entity.TopicIntervalAssociation;

@Repository
public class TopicIntervalAssociationDao extends GenericDataAccessObject<TopicIntervalAssociation> implements ITopicIntervalAssociationDao {

    @Override
    public TopicIntervalAssociation findByTopicIdAndIntervalId(long topicId, long intervalId) {
        final Map<String, Object> queryParams = new HashMap<String, Object>();
        queryParams.put("topicId", topicId);
        queryParams.put("intervalId", intervalId);
        return this.runSingleResultNamedQuery("TopicIntervalAssociation.FindByTopicIdAndIntervalId", queryParams, null);
    }

    @Override
    public List<TopicIntervalAssociation> findByTopicId(long topicId) {
        final Map<String, Object> queryParams = new HashMap<String, Object>();
        queryParams.put("topicId", topicId);
        return this.runNamedQuery("TopicIntervalAssociation.FindByTopicId", queryParams, null);
    }

}
